/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*************************************************************************
 *\author: starlove
 *************************************************************************/
#ifndef __CC_PYTHON_IMPORT_O_LABELATLAS_IMPL__
#define __CC_PYTHON_IMPORT_O_LABELATLAS_IMPL__

#include "python_object_labelatlas.h"
#include "python_object_texture2d.h"

NS_CCPY_BEGIN
	CCNODE_OBJECT_WRAPPER_IMPL(CCLabelAtlas, CPyLabelAtlas)	

	PYCLASS_INIT_AND_BASE_2(CPyLabelAtlas, CPyAtlasNode, CPyLabelProtocol, "CCLabelAtlas", "Python CCLabelAtlas Object");
	PYCLASS_BEGIN_METHOD_DEF(CPyLabelAtlas)
	PYCLASS_ADD_METHOD_EX(CPyLabelAtlas, initWithString, METH_KEYWORDS|METH_VARARGS)
	PYCLASS_ADD_METHOD(CPyLabelAtlas, updateAtlasValues)
	PYCLASS_END_METHOD_DEF(CPyLabelAtlas)
	PYCLASS_BEGIN_GETSET_DEF(CPyLabelAtlas)
	PYCLASS_END_GETSET_DEF(CPyLabelAtlas)
	PYCLASS_IMP_INTERFACE_NOINIT(CPyLabelAtlas)
	
	int CPyLabelAtlas::__init__(CPyLabelAtlas *pySelf, PyObject *pyArgs, PyObject *pyKW)
	{
		if( !pyArgs )
			return 0;
		static char* kwlist[] = {"string", "charMapFile", "itemWidth", "itemHeight", "startCharMap", "fntFile", NULL};
		char *string = NULL;
		char *charMapFile = NULL;
		unsigned int itemWidth = 0;
		unsigned int itemHeight = 0;
		unsigned int startCharMap = 0;
		char *fntFile = NULL;
		if(!PyArg_ParseTupleAndKeywords(pyArgs,pyKW,"|ssIIIs", kwlist, &string, &charMapFile, &itemWidth, &itemHeight, &startCharMap, &fntFile))
			return 0;
		if(!string)
			return 0;
		if(fntFile)
		{
			CC_METHOD_WRAPPER_GETER_RINT(cocos2d::CCLabelAtlas *, CPyLabelAtlas, initWithString, bool, string, fntFile);
		}else
		{
			CC_METHOD_WRAPPER_GETER_RINT(cocos2d::CCLabelAtlas *, CPyLabelAtlas, initWithString, bool, string, charMapFile, itemWidth, itemHeight, startCharMap);
		}
		return 0;
	}
	
	PYCLASS_METHOD_KW_IMPL(CPyLabelAtlas, initWithString)
	{
		if( !pyArgs )
			Py_RETURN_FALSE;
		static char* kwlist[] = {"string", "charMapFile", "itemWidth", "itemHeight", "startCharMap", "fntFile", "texture", NULL};
		char *string = NULL;
		char *charMapFile = NULL;
		unsigned int itemWidth = 0;
		unsigned int itemHeight = 0;
		unsigned int startCharMap = 0;
		char *fntFile = NULL;
		PyObject *texture = NULL;
		if(!PyArg_ParseTupleAndKeywords(pyArgs, pyKW,"|ssIIIsO", kwlist, &string, &charMapFile, &itemWidth, &itemHeight, &startCharMap, &fntFile, &texture))
			Py_RETURN_FALSE;
		if(!string)
			Py_RETURN_FALSE;
		if(fntFile)
		{
			CC_METHOD_WRAPPER_GETER_RINT(cocos2d::CCLabelAtlas *, CPyLabelAtlas, initWithString, bool, string, fntFile);
		}else
		{
			if(texture && PyObject_TypeCheck(texture, CPyClassBase::GetTypeObject<CPyTexture2D>()))
			{
				CPyTexture2D *tex = (CPyTexture2D *)texture;
				CC_METHOD_WRAPPER_GETER(cocos2d::CCLabelAtlas *, CPyLabelAtlas, initWithString, bool, string, (cocos2d::CCTexture2D *)tex->getCCObject(), itemWidth, itemHeight, startCharMap);
				Py_RETURN_BOOL(v);
			}else if(charMapFile)
			{
				CC_METHOD_WRAPPER_GETER(cocos2d::CCLabelAtlas *, CPyLabelAtlas, initWithString, bool, string, charMapFile, itemWidth, itemHeight, startCharMap);
				Py_RETURN_BOOL(v);
			}
		}
		Py_RETURN_FALSE;
	}
	
	PYCLASS_METHOD_IMPL(CPyLabelAtlas, updateAtlasValues)
	{
		CC_METHOD_WRAPPER_SETER(cocos2d::CCLabelAtlas *, CPyLabelAtlas, updateAtlasValues);
		Py_RETURN_NONE;
	}
	
NS_CCPY_END

#endif